<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
namespace App\Model;

use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model as BaseModel;
use Hyperf\ModelCache\Cacheable;
use Hyperf\ModelCache\CacheableInterface;

abstract class Model extends BaseModel
{
    use Cacheable;

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
    }

    const DELETED_AT = 'delete_time';
    const UPDATED_AT = 'update_time';
    const CREATED_AT = 'create_time';

    protected $dateFormat = 'U';
    protected static $ignore_corp = false;

    public function getUpdateTimeAttribute($value)
    {
        if (intval($value) == 0) {
            return '-';
        }
        return date('Y-m-d H:i:s', intval($value));
    }

    public function getLastLoginAttribute($value)
    {
        if (intval($value) == 0) {
            return '-';
        }
        return date('Y-m-d H:i:s', intval($value));
    }

    public function getCreateTimeAttribute($value)
    {
        if (intval($value) == 0) {
            return '-';
        }
        return date('Y-m-d H:i:s', intval($value));
    }

}
